package com.bgs.travelapp.weatherForecast.service.impl;

import com.bgs.travelapp.area.entity.AreaEntity;
import com.bgs.travelapp.weatherForecast.entity.WeatherEntity;
import com.bgs.travelapp.weatherForecast.mapper.WeatherMapper;
import com.bgs.travelapp.weatherForecast.service.WeatherService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import tk.mybatis.mapper.entity.Example;

import java.nio.file.WatchService;
import java.util.List;

@Service
public class WeatherServiceImpl implements WeatherService {

    @Autowired
    WeatherMapper weatherMapper;

    /**
     * 根据天气类型查询天气信息（前端）
     * hbx 2022年8月26日15:01:16
     * @param weatherType
     * @return
     */
    @Override
    public List<WeatherEntity> getWeatherByWeatherType(String weatherType) {
        Example example=new Example(WeatherEntity.class);
        Example.Criteria criteria =example.createCriteria();
        criteria.andLike("weatherType",weatherType);
        List<WeatherEntity> weatherEntities =weatherMapper.selectByExample(example);
        return weatherEntities;
    }

    /**
     * 查询天气所有信息
     * @return
     */
    @Override
    public List<WeatherEntity> getAllWeather() {
        Example example = new Example(WeatherEntity.class);
        return weatherMapper.selectByExample(example);
    }
}
